package com.hc.window;

import javax.swing.JDialog;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;

import com.hc.util.CommonData;
import com.hc.util.CommonView;
import com.hc.util.ToDoFileUtil;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class AddFolderDialog extends JDialog{
	private JTextField textField;
	public AddFolderDialog() {
		
		super(CommonView.mainWindow, true);
		
		setSize(500, 300);
		setTitle("\u6DFB\u52A0\u6587\u4EF6\u5939");
		getContentPane().setLayout(null);
		
		textField = new JTextField();
		textField.setText("");
		textField.setBounds(78, 69, 293, 35);
		getContentPane().add(textField);
		textField.setColumns(10);
		
		JLabel label = new JLabel("\u6587\u4EF6\u540D\uFF1A");
		label.setBounds(36, 29, 54, 27);
		getContentPane().add(label);
		
		JButton button = new JButton("\u786E\u5B9A");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				ToDoFileUtil.addFolder(textField.getText());
				
				CommonView.todoItemPanel.refreshView(CommonData.nowFilePath);
				
				AddFolderDialog.this.dispose();
				
			}
		});
		button.setBounds(149, 130, 134, 40);
		getContentPane().add(button);
		setLocationRelativeTo(null);
		this.setVisible(true);
		
	}
}
